package com.gitee.wsl.mathematics.complex.quaternion

import com.gitee.wsl.mathematics.vector.vec3.Vector3
import com.gitee.wsl.mathematics.vector.vec4.MutableVector4
import com.gitee.wsl.mathematics.vector.vec4.MutableVector4D
import com.gitee.wsl.mathematics.vector.vec4.MutableVector4F


/**
 * A class representing an effective rotation of a vector(x, y, z) by theta, where w = cos(theta/2).
 */
interface Quaternion<T:Number,V: Quaternion<T, V>>: MutableVector4<T, V> {

    override var length
        get() = sqrt(squaredLength)
        set(value) {
            val newQuat = normalized * value
            x = newQuat.x
            y = newQuat.y
            z = newQuat.z
            w = newQuat.w
        }

    //val euler: Vector3<T, *>

    //infix fun angleTo(other: V): T

    val conjugate  get() = create(-x, -y, -z, w)

}

interface QuaternionD<V: Quaternion<Double, V>> : Quaternion<Double, V>, MutableVector4D<V>

interface QuaternionF<V: Quaternion<Float, V>> : Quaternion<Float, V>, MutableVector4F<V>